package cn.yjr.service.impl;

import cn.yjr.entity.Order;
import cn.yjr.service.BaseService;
import cn.yjr.service.OrderService;
import cn.yjr.service.StorageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class BaseServiceImpl implements BaseService {

    @Autowired
    OrderService orderService;
    @Autowired
    StorageService storageService;



    @Override
    public void createOrder(Order order) {
        // 削减库存
        storageService.decreaseStorage(order);
        log.info("库存已扣减，商品代码:{}，购买数量:{}。创建订单中...", order.getCommodityCode(), order.getCount());
        // 创建订单
        orderService.addOrder(order);

    }

}
